Public Class PacketFunctions

    Public Shared Function ByteArrayToHex(ByVal data As Byte()) As String
        Try
            Dim b As Byte
            Dim sb As New System.Text.StringBuilder
            For Each b In data
                sb.Append(b.ToString("X2"))
                sb.Append(" "c)
            Next
            Return sb.ToString
        Catch ex As Exception
            gLog.LogError(ex)
            Return ""
        End Try
    End Function

    Public Shared Function ByteArrayToHex(ByVal data As Byte(), ByVal count As Integer) As String
        Try
            Dim i As Integer = 0
            Dim b As Byte
            Dim sb As New System.Text.StringBuilder
            For Each b In data
                i = i + 1
                If i > count Then Exit For
                sb.Append(b.ToString("X2"))
                sb.Append(" "c)
            Next
            Return sb.ToString
        Catch ex As Exception
            gLog.LogError(ex)
            Return ""
        End Try
    End Function
End Class
